//
//  LAWriteReviewModel.m
//  LYLazizDevelopDemo
//
//  Created by xbn_iMac on 2016/11/3.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LAWriteReviewModel.h"

@implementation LAWriteReviewModel

-(instancetype)init {
    self = [super init];
    if (self) {
        self.video_images = [NSMutableArray array];
        self.restaurant_images = [NSMutableArray array];
        self.restaurant_rating = self.restaurant_taste = self.restaurant_atmopsphere = self.restaurant_service = 0;
    }
    return self;
}

// **************************** 视频评价的属性的SET方法 ****************************
- (void)setVideo_rating:(NSInteger)video_rating {
    _video_rating = video_rating;
    [self judgeVideoTypeIsCanSubmit];
}

- (void)setVideo_reviewText:(NSString *)video_reviewText {
    _video_reviewText = [video_reviewText copy];
    [self judgeVideoTypeIsCanSubmit];
}

-(void)judgeVideoTypeIsCanSubmit {
    
    if (self.video_rating>0 && self.video_reviewText.length>0 && self.video_reviewText.length<1001) {
        if (self.canSubmitBlock) {
            self.canSubmitBlock(YES);
        }
    }
    else {
        if (self.canSubmitBlock) {
            self.canSubmitBlock(NO);
        }
    }
    
    if (self.video_rating>0 || self.video_reviewText.length>0) {
        if (self.canPopBlock) {
            self.canPopBlock(NO);
        }
    }
    else {
        if (self.canPopBlock) {
            self.canPopBlock(YES);
        }
    }
}

// **************************** 餐馆评价的属性的SET方法 ****************************
- (void)setRestaurant_rating:(NSInteger)restaurant_rating {
    _restaurant_rating = restaurant_rating;
    [self judgeRestaurantTypeIsCanSubmit];
}

- (void) setRestaurant_taste:(NSInteger)restaurant_taste {
    _restaurant_taste = restaurant_taste;
    [self judgeRestaurantTypeIsCanSubmit];
}

- (void) setRestaurant_atmopsphere:(NSInteger)restaurant_atmopsphere {
    _restaurant_atmopsphere = restaurant_atmopsphere;
    [self judgeRestaurantTypeIsCanSubmit];
}

- (void) setRestaurant_service:(NSInteger)restaurant_service {
    _restaurant_service = restaurant_service;
    [self judgeRestaurantTypeIsCanSubmit];
}

- (void) setRestaurant_reviewText:(NSString *)restaurant_reviewText {
    _restaurant_reviewText = [restaurant_reviewText copy];
    [self judgeRestaurantTypeIsCanSubmit];
}

-(void)judgeRestaurantTypeIsCanSubmit {
    
    if (self.restaurant_rating>0 || self.restaurant_taste>0 || self.restaurant_atmopsphere>0 || self.restaurant_service>0 || self.restaurant_reviewText.length>0 ) {
        if (self.canPopBlock) {
            self.canPopBlock(NO);
        }
    }
    else {
        if (self.isVideoReview) {
            [self judgeVideoTypeIsCanSubmit];
        }
        else {
            if (self.canPopBlock) {
                self.canPopBlock(YES);
            }
        }
    }
    
    if (self.isVideoReview) {
        return;
    }
    
    if (self.restaurant_rating>0 && self.restaurant_taste>0 && self.restaurant_atmopsphere>0 && self.restaurant_service>0 && self.restaurant_reviewText.length>0 && self.restaurant_reviewText.length<1001) {
        if (self.canSubmitBlock) {
            self.canSubmitBlock(YES);
        }
    }
    else {
        if (self.canSubmitBlock) {
            self.canSubmitBlock(NO);
        }
    }
}

- (BOOL)writeVideoReviewTypeRestaurantIsComplete {
    if (self.restaurant_rating>0 && self.restaurant_taste>0 && self.restaurant_atmopsphere>0 && self.restaurant_service>0 && self.restaurant_reviewText.length>0 && self.restaurant_reviewText.length<1001) {
        return YES;
    }
    else if (self.restaurant_rating==0 && self.restaurant_taste==0 && self.restaurant_atmopsphere==0 && self.restaurant_service==0 && self.restaurant_reviewText.length==0)
    {
        return YES;
    }
    else {
        return NO;
    }
}

@end
